package cn.edu.xmu.datamining.tangzk.util;

public class MyUtil {

	public static String formatInt(int i) {
		String str;
		if (i == Integer.MAX_VALUE) {
			str = "MAX";
		} else if (i == Integer.MIN_VALUE) {
			str = "MIN";
		} else {
			str = String.valueOf(i);
		}
		return str;
	}

	public static int parseInt(String in) {
		if ("MAX".equals(in.toUpperCase())) {
			return Integer.MAX_VALUE;
		} else if ("MIN".equals(in.toUpperCase())) {
			return Integer.MIN_VALUE;
		} else {
			int d = 0;
			try {
				d = Integer.parseInt(in);
			} catch (NumberFormatException nfe) {
				nfe.printStackTrace();
				d = 0;
			}
			return d;
		}
	}
}
